function queue(nums) {
  let promise = Promise.resolve();
  return nums.map(n => {
    promise = promise.then(v => {
      return new Promise(resolve => {
       setTimeout(() => {
       	 console.log(n);
         resolve(n);
       }, 2000)
      });

    });

    console.log('n = ', n)
    return promise
  });
}



var ret = queue([1,2,4])
Promise.all(ret).then(results => {
	// 最后完成, 即收集的n个promise都执行成功后， 为执行该方法
	console.log('promise.all results = ', results)
})

setTimeout(() => {
	console.log(ret)
	
}, 2000 * 3)
